/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Logon.java
 *
 * Created on 2011-6-23, 10:26:02
 */
package seso;

import org.jdesktop.application.Action;

/**
 *
 * @author Administrator
 */
public class SelectProfile extends javax.swing.JFrame {

    private String userName = "";
    
    /** Creates new form Logon */
    public SelectProfile() {
        super();
        initComponents();
        setControl();
    }
    
    public SelectProfile(String userName) {
        super();
        this.userName = userName;
        
        initComponents();
        setControl();
    }    

    private void setControl()   {
        setIconImage(Util.getLogoImage());
        //setLocationRelativeTo(null);
        
        setScreenCenter(jLabelBackground.getWidth(), jLabelBackground.getHeight());
        
        getRootPane().setDefaultButton(this.cmdOK);    
        cmdOK.requestFocus();
       }
    
    private void setScreenCenter(int width, int height) {
        setSize(width, height);
        setPreferredSize(new java.awt.Dimension(width, height));
        setLocationRelativeTo(null);
    }
    
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        dataProfileFld = new seso.RComboBox();
        cmdOK = new seso.RBgButton();
        cmdCancel = new seso.RBgButton();
        jLabelBackground = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(seso.SesoApp.class).getContext().getResourceMap(SelectProfile.class);
        setBackground(resourceMap.getColor("Form.background")); // NOI18N
        setLocationByPlatform(true);
        setName("Form"); // NOI18N
        setResizable(false);
        setUndecorated(true);
        getContentPane().setLayout(null);

        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setOpaque(false);
        jPanel1.setLayout(null);

        dataProfileFld.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "TEST-PL", "DEMO-PL" }));
        dataProfileFld.setName("dataProfileFld"); // NOI18N
        jPanel1.add(dataProfileFld);
        dataProfileFld.setBounds(173, 370, 147, 20);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(seso.SesoApp.class).getContext().getActionMap(SelectProfile.class, this);
        cmdOK.setAction(actionMap.get("cmdOKAction")); // NOI18N
        cmdOK.setIcon(resourceMap.getIcon("cmdOK.icon")); // NOI18N
        cmdOK.setText(resourceMap.getString("cmdOK.text")); // NOI18N
        cmdOK.setName("cmdOK"); // NOI18N
        cmdOK.setPressedIcon(resourceMap.getIcon("cmdOK.pressedIcon")); // NOI18N
        cmdOK.setRolloverIcon(resourceMap.getIcon("cmdOK.rolloverIcon")); // NOI18N
        cmdOK.setSelectedIcon(resourceMap.getIcon("cmdOK.selectedIcon")); // NOI18N
        jPanel1.add(cmdOK);
        cmdOK.setBounds(243, 398, 120, 29);

        cmdCancel.setAction(actionMap.get("cmdCancelAction")); // NOI18N
        cmdCancel.setIcon(resourceMap.getIcon("cmdCancel.icon")); // NOI18N
        cmdCancel.setText(resourceMap.getString("cmdCancel.text")); // NOI18N
        cmdCancel.setName("cmdCancel"); // NOI18N
        cmdCancel.setPressedIcon(resourceMap.getIcon("cmdCancel.pressedIcon")); // NOI18N
        cmdCancel.setRolloverIcon(resourceMap.getIcon("cmdCancel.rolloverIcon")); // NOI18N
        cmdCancel.setSelectedIcon(resourceMap.getIcon("cmdCancel.selectedIcon")); // NOI18N
        jPanel1.add(cmdCancel);
        cmdCancel.setBounds(363, 398, 120, 29);

        getContentPane().add(jPanel1);
        jPanel1.setBounds(0, 0, 503, 446);

        jLabelBackground.setBackground(resourceMap.getColor("jLabelBackground.background")); // NOI18N
        jLabelBackground.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelBackground.setIcon(resourceMap.getIcon("jLabelBackground.icon")); // NOI18N
        jLabelBackground.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jLabelBackground.setName("jLabelBackground"); // NOI18N
        getContentPane().add(jLabelBackground);
        jLabelBackground.setBounds(0, 0, 503, 446);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */

                
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new SelectProfile().setVisible(true);
            }
        });
    }                

    @Action
    public void cmdOKAction() {
        HomePage form = new HomePage(userName, dataProfileFld.getSelectedItem().toString());
        form.setLocationRelativeTo(null);
        dispose();
        SesoApp.getApplication().show(form);
    }

    @Action
    public void cmdCancelAction() {
        dispose();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private seso.RBgButton cmdCancel;
    private seso.RBgButton cmdOK;
    private seso.RComboBox dataProfileFld;
    private javax.swing.JLabel jLabelBackground;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
}
